<template>
  <Overlay :show="showPopup">
    <van-icon name="close" class="btn-close" @click.stop="showPopup = false" />
    <div class="preview-content">
      <video :src="item.url" autoplay muted loop />
      <div class="info">
        <div class="title">
          {{ item.gridName }}
        </div>
        <div class="type-name">
          <span class="type">{{ item.videoType }}</span>
          <div class="sep" />
          <span class="name">{{ item.cameraName }}</span>
        </div>
      </div>
    </div>
  </Overlay>
</template>

<script setup lang="ts">
import { Overlay } from 'vant'
import { useVModel } from '@vueuse/core'

const props = defineProps<{
  visible: boolean
  item: TypeVidItem
}>()

const emit = defineEmits(['update:visible'])

const showPopup = useVModel(props, 'visible', emit)
</script>

<style scoped lang="less">
.preview-content {
  z-index: 99;
  width: 100%;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);

  video {
    height: 211px;
    width: 100%;
    background: #000;
  }
}

.info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 64px;
  padding: 0px 16px;
  background: #00000099;
  color: #fff;
  .title {
    font-weight: bold;
    font-size: 16px;
    color: #fff;
  }

  .type-name {
    margin-top: 12px;
    font-size: 13px;
    color: #ffffffcc;
    display: flex;
    align-items: center;
    .sep {
      margin-right: 6px;
      margin-left: 6px;
      height: 10px;
      width: 1px;
      background-color: #d9d9d9;
    }
  }
}

.btn-close {
  position: absolute;
  font-size: 25px;
  color: #fff;
  left: 15px;
  top: 55px;
}
</style>
